package com.other.dispatchEvent;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.LinearLayout;

import com.base.tool.log.Tags;


public class MyLinearLayout extends LinearLayout {

    private static final String TAG = Tags.myLinearLayout;

    public MyLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);

    }


    @Override

    public boolean dispatchTouchEvent(MotionEvent event) {
        Log.e(TAG, "dispatchTouchEvent begin "+ UtilMotionEvent.show(event));

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                break;

            case MotionEvent.ACTION_MOVE:
                break;

            case MotionEvent.ACTION_UP:
                break;

        }


//        true表示不再继续分发，事件被消费了。返回false则事件继续分发
        boolean result = super.dispatchTouchEvent(event);
        Log.e(TAG, "dispatchTouchEvent " + (result ? "不再继续分发" : "事件继续分发")+ " "+UtilMotionEvent.show(event));

        return result;

    }


    @Override

    public boolean onInterceptTouchEvent(MotionEvent event) {
        Log.e(TAG, "onInterceptTouchEvent begin " + UtilMotionEvent.show(event));

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                break;

            case MotionEvent.ACTION_MOVE:
                break;

            case MotionEvent.ACTION_UP:
                break;

        }


//        true表示不再继续分发，事件被消费了。返回false则事件继续分发
        boolean result = super.onInterceptTouchEvent(event);
        Log.e(TAG, "onInterceptTouchEvent end " + (result ? "拦截" : "不拦截") + " " + UtilMotionEvent.show(event));

        return result;

    }


    @Override

    public boolean onTouchEvent(MotionEvent event) {
        Log.e(TAG, "onTouchEvent begin "+ UtilMotionEvent.show(event));

        switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:
                break;

            case MotionEvent.ACTION_MOVE:
                break;

            case MotionEvent.ACTION_UP:
                break;

        }

        boolean result = super.onTouchEvent(event);
        Log.e(TAG, "onTouchEvent end" + (result ? "事件已经消费" : "事件没消费") + " " + UtilMotionEvent.show(event));

        return result;
    }

}
